無法恢復 pg_dump 備份 (Unable to restore pg_dump backup)


問題描述

無法恢復 pg_dump 備份 (Unable to restore pg_dump backup)

I'm trying to restore backup from Postgres 9.1.1, which was created by:

pg_dump mydb > backup.sql

restore on Postgres 9.1.9

psql ‑d mydb ‑f backup.sql

I'm getting this error:

psql:datasets.sql:278537: invalid command \.
psql:datasets.sql:278544: ERROR:  syntax error at or near "1"
LINE 1: 1 4446 49 253.412262 239.618317 0 211.54303 100.482948 197.1...

The \. is part of COPY command, I guess it should be compatible between Postgres 9 versions, or it's not?

COPY data_136 (id, in_1, in_2, in_3, in_4, out_1) FROM stdin;
1       5.0999999       3.5     1.39999998      0.200000003     Iris‑setosa
2       4.9000001       3       1.39999998      0.200000003     Iris‑setosa
‑‑‑ few more line cutted
150     5.9000001       3       5.0999999       1.79999995      Iris‑virginica
\.

參考解法

方法 1:

The problem was caused by earlier error: 

ERROR:  permission denied for schema pg_catalog

I was importing the under user who has all privileges to databases, anyway running the import under postgres user solved the issue.

方法 2:

This error occurred to me for the same reason: I was logged in as a user with insufficient permissions. 

Just for completeness I'll mention how you can do the restoring whilst specifying the user performing the action:

psql ‑U postgres ‑d mydb ‑f backup.sql

(by TombartTombartmclaeysb)

參考文件

  1. Unable to restore pg_dump backup (CC BY‑SA 3.0/4.0)

#pg-dump #psql #postgresql-9.1 #postgresql






相關問題

如何檢查我是否只刪除了所需的數據? (How do I check that I removed required data only?)

無法恢復 pg_dump 備份 (Unable to restore pg_dump backup)

使用帶有 Curl 的緩衝輸出將文件上傳到 ftp 服務器 (Upload a file into a ftp server using buffered output with Curl)

帶有 -C 選項的 pg_restore 不會創建數據庫 (pg_restore with -C option does not create the database)

pg_dump 數據庫轉儲是“當時”轉儲嗎? (Is a pg_dump DB dump 'at-that-time' dump?)

PSQL 數據庫傳輸和錯誤 (PSQL database transfer and errors)

Postgres pg_dump 顯示空文件 (Postgres pg_dump show empty file)

將 pg_restore 與多個轉儲一起使用時管理外鍵 (Managing foreign keys when using pg_restore with multiple dumps)

設計:在不斷創建和刪除表時運行 pg_dump (Design: running pg_dump when tables are continuously created and dropped)

轉儲文件中視圖預定義的目的是什麼 (What is the purpose of views' predefinitions in dump file)

如何附加 pg_dump 備份命令 PostgreSQL 的日誌輸出 (How to append log output of pg_dump backup command PostgreSQL)

PostgreSQL:單個表的 pg_dump (PostgreSQL: pg_dump for a single table)







留言討論